package com.europe.business.europebusiness.ui.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.ViewGroup;

import com.europe.business.europebusiness.ui.adapter.viewholder.ListViewHolder;

import java.util.List;

/**
 * 通用的多类型的adapter
 * @param <T>
 */
public abstract class MutilItemCommonAdapter1<T> extends ListAdapter1<T> {
    MultiItemTypeSupport multiItemTypeSupport;
    public static final int VIWE_TYPE_FOOT = 1;
    public static final int VIWE_TYPE_DATA = 0;
    private int isHaveFoot;



    public MutilItemCommonAdapter1(Context context, List<T> datas, MultiItemTypeSupport multiItemTypeSupport, ItemClicked itemClicked) {
        super(context, datas, -1, itemClicked);
        isHaveFoot = 0;
        this.multiItemTypeSupport = multiItemTypeSupport;
    }


    public int getDataCount(){
        return  mDatas.size();
    }

    public void setIsHaveFoot(int isHaveFoot) {
        this.isHaveFoot = isHaveFoot;
    }

    @Override
    public int getItemCount() {
        return mDatas.size() + isHaveFoot;
    }

    @Override
    public int getItemViewType(int position) {
        return multiItemTypeSupport.getItemViewType(position);
    }

    @NonNull
    @Override
    public ListViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        int layoutId = multiItemTypeSupport.getLayoutId(i);
        return  ListViewHolder.getViewHold(mContext, layoutId, viewGroup);
    }

}
